<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑应用服务 - API文档管理系统</title>
    <link th:href="@{/css/bootstrap/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap/font/bootstrap-icons.css}" rel="stylesheet">
    <link th:href="@{/css/style.css}" rel="stylesheet">
</head>
<body>
    <div class="container-fluid">
        <!-- 导航栏 -->
        <nav class="navbar navbar-expand-lg navbar-dark bg-primary mb-4">
            <div class="container-fluid">
                <a class="navbar-brand" th:href="@{/api-doc/}">
                    <i class="bi bi-book"></i>
                    API文档管理系统
                </a>
                <div class="navbar-nav ms-auto">
                    <a class="nav-link" th:href="@{/api-doc/}">
                        <i class="bi bi-house"></i>
                        首页
                    </a>
                    <a class="nav-link" th:href="@{/api-doc/list}">
                        <i class="bi bi-list"></i>
                        API列表
                    </a>
                    <a class="nav-link" th:href="@{/api-doc/app-service/list}">
                        <i class="bi bi-server"></i>
                        应用服务
                    </a>
                    <a class="nav-link" th:href="@{/api-doc/create}">
                        <i class="bi bi-plus-circle"></i>
                        新增API
                    </a>
                    <a class="nav-link" th:href="@{/swagger-ui/index.html}" target="_blank">
                        <i class="bi bi-code-square"></i>
                        Swagger UI
                    </a>
                </div>
            </div>
        </nav>

        <!-- 错误信息显示 -->
        <div th:if="${error}" class="alert alert-danger alert-dismissible fade show" role="alert">
            <i class="bi bi-exclamation-triangle"></i>
            <span th:text="${error}"></span>
            <button type="button" class="btn-close" data-dismiss="alert"></button>
        </div>

        <!-- 编辑应用服务表单 -->
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <div class="card">
                    <div class="card-header">
                        <h5 class="card-title mb-0">
                            <i class="bi bi-pencil"></i>
                            编辑应用服务
                        </h5>
                    </div>
                    <div class="card-body">
                        <form action="#" th:action="@{/api-doc/app-service/edit/{id}(id=${appService.id})}" th:object="${appServiceRequest}" method="post">
                            <!-- 服务基本信息 -->
                            <div class="mb-3">
                                <label for="name" class="form-label">
                                    <i class="bi bi-bookmark"></i>
                                    服务名称 *
                                </label>
                                <input type="text" class="form-control" id="name" name="name" th:value="${appService.name}" required>
                                <div class="form-text">请输入应用服务的名称，如"用户服务"</div>
                            </div>

                            <div class="mb-3">
                                <label for="description" class="form-label">
                                    <i class="bi bi-chat-text"></i>
                                    服务描述
                                </label>
                                <textarea class="form-control" id="description" name="description" rows="3" th:text="${appService.description}"></textarea>
                                <div class="form-text">请输入应用服务的详细描述信息</div>
                            </div>

                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label for="ipAddress" class="form-label">
                                        <i class="bi bi-globe"></i>
                                        IP地址 *
                                    </label>
                                    <input type="text" class="form-control" id="ipAddress" name="ipAddress" th:value="${appService.ipAddress}" placeholder="127.0.0.1" required>
                                    <div class="form-text">请输入服务器的IP地址</div>
                                </div>

                                <div class="col-md-6 mb-3">
                                    <label for="port" class="form-label">
                                        <i class="bi bi-plug"></i>
                                        端口 *
                                    </label>
                                    <input type="number" class="form-control" id="port" name="port" th:value="${appService.port}" placeholder="8080" min="1" max="65535" required>
                                    <div class="form-text">请输入服务端口号</div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label for="protocol" class="form-label">
                                        <i class="bi bi-shield-lock"></i>
                                        协议
                                    </label>
                                    <select class="form-select" id="protocol" name="protocol">
                                        <option value="http" th:selected="${appService.protocol == 'http'}">HTTP</option>
                                        <option value="https" th:selected="${appService.protocol == 'https'}">HTTPS</option>
                                    </select>
                                </div>

                                <div class="col-md-6 mb-3">
                                    <label for="contextPath" class="form-label">
                                        <i class="bi bi-folder"></i>
                                        上下文路径
                                    </label>
                                    <input type="text" class="form-control" id="contextPath" name="contextPath" th:value="${appService.contextPath}" placeholder="/">
                                    <div class="form-text">请输入应用的上下文路径</div>
                                </div>
                            </div>

                            <div class="mb-3">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="enabled" name="enabled" value="true" th:checked="${appService.enabled}">
                                    <label class="form-check-label" for="enabled">
                                        <i class="bi bi-check-circle"></i>
                                        启用服务
                                    </label>
                                </div>
                                <div class="form-text">是否启用此应用服务</div>
                            </div>

                            <!-- 操作按钮 -->
                            <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                                <a th:href="@{/api-doc/app-service/list}" class="btn btn-secondary me-md-2">
                                    <i class="bi bi-arrow-left"></i>
                                    返回列表
                                </a>
                                <button type="reset" class="btn btn-outline-secondary me-md-2">
                                    <i class="bi bi-arrow-counterclockwise"></i>
                                    重置
                                </button>
                                <button type="submit" class="btn btn-primary">
                                    <i class="bi bi-save"></i>
                                    保存服务
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script th:src="@{/js/jquery-3.6.0.min.js}"></script>
    <script th:src="@{/js/bootstrap/bootstrap.bundle.min.js}"></script>
</body>
</html>